package com.apes.fn.scm.settleCheck.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.finance.model.IncomeType;
import com.apes.scm.masterdata.product.model.Classify;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 功能：结算政策平类优先固定比例
 *
 * @author zhuyh
 * @time 15:31
 * @date 2020/5/30
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PartnerCheckClassify.CONST_TABLE_NAME)
public class PartnerCheckClassify extends Model {
    public static final String CONST_TABLE_NAME = "fn_partner_check_classify";

    @Id
    @Column(name = "id", length = 24, nullable = false)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "赋能结算比例特殊处理", padding = 12)
    private String id;


    @ManyToOne(optional = false)
    @JoinColumn(name = "partner_check_id", referencedColumnName = "id")
    @Comment("决策单号")
    private PartnerCheck partnerCheck;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "expense_type_id", referencedColumnName = "id")
    @Comment("费用类型")
    private IncomeType expenseType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "classify_id", referencedColumnName = "id")
    @Comment("商品分类编码")
    private Classify classify;  //商品分类

    @Column(name = "rate", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("固定费率")
    private double rate = 0.0;  //费率
}
